﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nvigorate.Relational.Repository;
using Nvigorate.Relational.State;
using PostSharp.Extensibility;
using PostSharp.Laos;

namespace Nvigorate.Aspect
{
    [Serializable]
    [MulticastAttributeUsage(MulticastTargets.Method)]
    public class ForbidLazyLoadingAspect : OnMethodBoundaryAspect
    {
        public override void OnEntry(MethodExecutionEventArgs eventArgs)
        {
            LazyLoadingProxy.LockLazyLoading();
        }

        public override void OnExit(MethodExecutionEventArgs eventArgs)
        {
            LazyLoadingProxy.ReleaseLazyLoading();
        }
    }
}
